package edu.zut.cs.software.example.space.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.example.service.impl.GenericManagerImpl;
import edu.zut.cs.software.example.space.dao.SpaceDao;
import edu.zut.cs.software.example.space.domain.Space;
import edu.zut.cs.software.example.space.service.SpaceManager;

/**
 * 
 * @author ma jiang tao
 *
 */

@Service
public class SpaceManagerImpl extends GenericManagerImpl<Space, Long> implements SpaceManager {

	SpaceDao spaceDao;

	/*
	 * @Override public List<Space> findBymessage(String message) { // 创建查询条件数据对象
	 * Space queryObject=new Space(); queryObject.setMessage(message); //
	 * 创建匹配器，即如何使用查询条件 ExampleMatcher matcher = ExampleMatcher.matching() // 构建对象
	 * .withStringMatcher(StringMatcher.CONTAINING) // 改变默认字符串匹配方式：模糊查询
	 * .withMatcher("message", GenericPropertyMatchers.contains()) //
	 * 姓名采用“开始匹配”的方式查询 .withIgnorePaths("dateCreated", "dateModified"); //
	 * 忽略属性：是否关注。因为是基本类型，需要忽略掉
	 * 
	 * 
	 * // 创建实例并查询 Example<Space> ex = Example.of(queryObject, matcher); List<Space>
	 * result = this.spaceDao.findAll(ex); return result; }
	 */

	@Autowired
	public void setSpaceDao(SpaceDao spaceDao) {
		this.spaceDao = spaceDao;
		this.dao = this.spaceDao;
	}

	

	@Override
	public int getSpaceBymessageCounts(String message) {
		int numbers = spaceDao.getSpaceBymessageCounts(message);
		return numbers;
	}


	@Override
	public List<Space> findBymessage(String message, int pagenum, int pageSize) {
		List<Space> Space= spaceDao.findBymessage(message, pagenum, pageSize);
		return Space;
	}
    
	
	@Override
	public int deleteById(int id) {
		int i=spaceDao.deleteById(id);
		return i;
	}

	@Override
	public Space getUpdateSpaService(int id) {
		return spaceDao.getUpdateSpace(id);
	}
	
	@Override
	public int editspace(Space space) {
		Long ID=space.getId();
		String dynamic=space.getDynamic();
		String message=space.getMessage();
		
		return spaceDao.editspace(dynamic, message,ID);
	}

	@Override
	public List<Space> findByStudentId(Long studentid, int pagenum, int pageSize) {
		List<Space> Space=spaceDao.findByStudentId(studentid, pagenum, pageSize);
		return Space;
	}

	@Override
	public int getSpaceByStudentIdCounts(Long studentid) {
		int numbers=spaceDao.getSpaceByStudentIdCounts(studentid);
		return numbers;
	}

	
}
